<?php
class LogUtility
{
    public static function import($date)
    {
        // truncate old log
        LogModel::truncate();
        
        // import new log
        $path = Yii::app()->params[ENUM_CONFIG_PARAM_LOG_SCRIBE_PATH];
        $date = str_replace('-', '', $date);
        $counter = 0;
        do
        {
            // file
            $file = '/oakclub_%s/oakclub_%s_%s';
            $file = $path.sprintf($file, $date, $date, str_pad($counter, 5, 0, STR_PAD_LEFT));
            if(!file_exists($file))
            {
                break;
            }
            
            // import log
            LogModel::import($file);
            
            // next
            $counter++;
        }
        while(1);
        
        // delivery log
        LogModel::delivery();
    }
    
    public static function delete($date)
    {
        LogModel::delete($date);
        
    }
}